<?php
/**
 * Course Class Model
 *
 * Copyright 2012
 * @date 21-April-2012
 * @author 
 * @version 0.0.1
 **/
class QuestionOption extends AppModel {
/**
 * Name
 *
 * @var string
 */
    public $name = 'QuestionOption';
    public $useTable = "questions_options";
    public $belongsTo = array(
        'Question'=>array(
            'className'=>'Question',
            'foreignKey'=>'question_id'
        ),
        'Option'=>array(
            'className'=>'Option',
            'foreignKey'=>'option_id'
        )
    );
    
    public static function get_options_by_question($customer_id) {
        $sq = ClassRegistry::init("QuestionOption");
        $sq->unbindModel(array("belongsTo"=>array("Question")));
        return $sq->find("all",array('conditions'=>array('question_id'=>$customer_id)));
    }
    public function delete_options_by_question($customer_id) {
        return $this->query("Delete from questions_options where question_id=$customer_id");
    }
    public function delete_option_question($surveys_id,$question_id) {
        return $this->query("Delete from questions_options where option_id=$surveys_id AND question_id=$question_id");
    }
}